<?php
namespace App\Models\Operation;

use App\Models\Base\Photo;
use App\Models\Base\Task;
use App\Models\Garage\Vehicle;
use App\Models\Garage\Garage;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphOne;

class WarehouseEntry extends BaseModel
{
    protected $table = 'beesoft_warehouse_entries';
    protected $fillable = [
        'name',
        'email',
    ];

    public static function getTypes(): array {
        return [
            1 => '普通入库',
        ];
    }
    public static function getAreas() {
        return self::pluck('title', 'id')->toArray();
    }

    // 关联
    public function vehicle() {
        return $this->belongsTo(Vehicle::class);
    }
    public function garage() {
        return $this->belongsTo(Garage::class);
    }

    public function task(): MorphOne
    {
        return $this->morphOne(Task::class, 'morph');
    }
    public function photos(): MorphMany
    {
        return $this->morphMany(Photo::class, 'morph');
    }
}
